<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="/js/qrcode.min.js"></script>
<script type="text/javascript" src="/js/jquery-1.8.2.min.js"></script>
</head>
<body>
	<div id="qrcode" ></div><button onclick="queryStatus()" value="查询状态"></button>

	<script type="text/javascript">
		//显示二维码
		new QRCode(document.getElementById("qrcode"), "${code_url}");




        function queryStatus(){
            $.ajax({
                type: 'post',
                url: '/WxPay/OrderQuery',
                data: {orderNO:"${orderNO}"},
                success: function(str){
                    console.log(str);
                    if('SUCCESS' == str){
                        location.href='success.jsp?orderNO=${orderNO}';
                    }
                },
                error: function(){
                    alert('执行错误！');
                }
            });
        }

		<%--//轮询订单是否支付成功--%>
		<%--var t1 = window.setInterval('queryStatus()', 5000);--%>
		
		<%--function queryStatus(){--%>
			<%--$.ajax({--%>
				<%--type: 'post',--%>
				<%--url: '/WxPay/OrderQuery',--%>
				<%--data: {orderNO:"${orderNO}"},--%>
				<%--success: function(str){--%>
					<%--console.log(str);--%>
					<%--if('SUCCESS' == str){--%>
						<%--location.href='success.jsp?orderNO=${orderNO}';--%>
					<%--}--%>
				<%--},--%>
				<%--error: function(){--%>
					<%--alert('执行错误！');--%>
				<%--}--%>
			<%--});--%>
		<%--}--%>
	</script>
</body>
</html>